CMAKE_MINIMUM_REQUIRED(VERSION 2.8)


include_directories(${LITEPLAYER_INCLUDES})
include_directories(${COMN_DIR}/include)
include_directories(${GLOOX_DIR}/src)
include_directories(${PROJECT_ROOT}/RtpCaster)
include_directories(${PROJECT_ROOT}/RtspCaster)
include_directories(${PROJECT_ROOT}/RtspRelay)

link_directories(${LITEPLAYER}/lib)
link_directories(${COMN_DIR}/lib)
link_directories(${GLOOX_DIR}/lib)

if (MSVC)
	SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
else()
endif()

aux_source_directory(. SOURCES)

add_executable(LiveRelayServer ${SOURCES})

target_link_libraries(LiveRelayServer
	${LIB_PLATFORM}
	debug comnd optimized comn
	RtpCaster
	RtspCaster
	RtspRelay
	${GLOOX_LIBS}
	)


set(VERSION_MAJOR "1")
set(VERSION_MINOR "1")
set(VERSION_PATCH "0")

install(TARGETS LiveRelayServer DESTINATION .)

set(CMAKE_INSTALL_SYSTEM_RUNTIME_DESTINATION .)
include(InstallRequiredSystemLibraries)


set(CPACK_PACKAGE_NAME "LiveRelayServer")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "live relay server")
set(CPACK_PACKAGE_VENDOR "100wits.com")

set(CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
	
if(UNIX)
	SET(CPACK_GENERATOR "TGZ")
	
else()
	SET(CPACK_GENERATOR "ZIP")
endif()

if(WIN32)
	install(FILES ${PROJECT_ROOT}/LiveRelayServer/LiveRelay.ini DESTINATION .)
	
	install(DIRECTORY ${THIRD_PARTY}/ffmpeg/bin/ DESTINATION . FILES_MATCHING PATTERN "*.dll")
else()
	install(FILES ${PROJECT_ROOT}/LiveRelayServer/LiveRelay.ini DESTINATION etc)
endif()

set(CPACK_OUTPUT_FILE_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/../dist") 
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") 

include(CPack)	
